﻿using FarmSmartSleep.Common.Domain.BodyWeight;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.SleepWeightCommands
{
    public class WeightTypeSearchHandler : IRequestHandler<WeightTypeSearchCommand, Result>
    {
        private readonly IBaseRepository<WeightTypes> weighttypebaseRepository;

        public WeightTypeSearchHandler(IBaseRepository<WeightTypes> weighttypebaseRepository)
        {
            this.weighttypebaseRepository = weighttypebaseRepository;
        }
        /// <summary>
        /// 称重类型下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Result> Handle(WeightTypeSearchCommand request, CancellationToken cancellationToken)
        {
            var result= new Result() { Code=(int)CodeEnum.search};
            var list= weighttypebaseRepository.GetAll().ToList();
            result.Data = list;
            return result;
        }
    }
}
